package com.heima.user.controller;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.AddUser;
import com.heima.model.user.pojos.GetCode;
import com.heima.model.user.pojos.LoginDto;
import com.heima.user.service.ApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/login")
@Api(value = "app端用户登录", tags = "ap_user", description = "app端用户登录API")
public class ApUserLoginController {

    @Autowired
    private ApUserService apUserService;

    @PostMapping("/login_auth")
    @ApiOperation("用户登录")
    public ResponseResult login(@RequestBody LoginDto longinDto){


        return apUserService.login(longinDto);
    }

    /**
     * 验证码发送
     * @param phone
     * @return
     */
    @PostMapping("/register/{phone}")
    @ApiOperation("验证码发送")
    public ResponseResult register(@PathVariable String phone){

        apUserService.register(phone);

        return ResponseResult.okResult(200,"验证码发送成功，请注意查收");
    }

    /**
     * 验证码的校验
     * @param getCode
     * @return
     */
    @PostMapping("/getcode")
    @ApiOperation("验证码校验")
    public ResponseResult getcode(@RequestBody GetCode getCode){

       return apUserService.getcode(getCode);


    }

    @PostMapping("/adduser")
    public ResponseResult adduser(@RequestBody AddUser addUser){

        return apUserService.adduser(addUser);

    }


}
